#include "ChessBoardLayer.h"
#include "ImageResources.h"
#include "GameEntity.h"

ChessBoardLayer::ChessBoardLayer() {
}


ChessBoardLayer::~ChessBoardLayer() {
}

void ChessBoardLayer::Render(ID2D1HwndRenderTarget* pRenderTarget) {
	D2D1_RECT_F destinationRectangle = D2D1::RectF(m_x, m_y, m_w+m_x, m_h + m_y);
	D2D1_RECT_F sourceRectangle = D2D1::RectF(0, 0, m_w, m_h);
	pRenderTarget->DrawBitmap(bmpChessboard, &destinationRectangle, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &sourceRectangle);
	for (int i = 0; i < 15; i++) {
		int startX = m_startX + i * m_eachW + m_x - 16;
		int endX = startX + m_chessW;
		for (int j = 0; j < 15; j++) {
			if (gameMap[i][j] == CHESS_BLACK) {
				int startY = m_startY + j * m_eachW + m_y - 16;
				int endY = startY + m_chessW;
				D2D1_RECT_F r1 = D2D1::RectF(startX, startY, endX, endY);
				D2D1_RECT_F r2 = D2D1::RectF(0, 0, m_chessW, m_chessW);
				pRenderTarget->DrawBitmap(bmpChessBlack, &r1, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &r2);
			}
		}
	}

	/*for (int i = 0; i < 15; i++) {
		int startX = m_startX + i * m_eachW + m_x-16;
		int endX = startX + m_chessW;
		for (int j = 0; j < 15; j++) {
			int startY = m_startY + j * m_eachW + m_y-16;
			int endY = startY + m_chessW;
			D2D1_RECT_F r1 = D2D1::RectF(startX, startY, endX, endY);
			D2D1_RECT_F r2 = D2D1::RectF(0, 0, m_chessW, m_chessW);
			pRenderTarget->DrawBitmap(bmpChessBlack, &r1, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR,&r2);
		}
	}*/
}